<?php
class Solicitudes_Form_Sintesis extends Form_Cna {
	
	private $titulo;
	private $textoSintesis;
	private $requerido;
	
	public function __construct($options = null) {
		parent::__construct($options);
	}
	
	public function init($a=false) {
		$domConfig = Zend_Registry::get('domConfig');
		$appConfig = Zend_Registry::get('appConfig');
		
		$sesionTabBoton = new Zend_Session_Namespace("TABBOTON");
		
		$this->setName('sintesis');
		$this->setMethod("post");
		$this->setEnctype('multipart/form-data');
		
		$array_elements[] = new Zend_Form_Element_Hidden("codtab");
		$array_elements[] = new Zend_Form_Element_Hidden("codboton");
		$array_elements[] = new Zend_Form_Element_Hidden("codboton2");
		$array_elements[] = new Zend_Form_Element_Hidden("codsintesis");
		      
		$element = new Zend_Form_Element_Textarea('contenido');
		$element->setLabel('Síntesis :');
		$element->setRequired(true);
		$element->addFilter('StripTags');
		$element->addFilter('StringTrim');
//		$element->addFilter('StringToUpper');
		$element->setAttrib("rows",10);
		$element->setAttrib("style","width:99%");
//		if(in_array($sesionTabBoton->opcion,array("3_3_3","3_3_4","3_3_5","3_3_6","3_3_7","3_3_8","3_3_9","3_3_10"))){
//		    $element->addValidator('StringLength', false, array(10));
//		}else{
		    $element->addValidator('StringLength', false, array($domConfig->TEXTO_TAMANOMIN));
//		}
		$array_elements[] = $element;
		
		if(!in_array($sesionTabBoton->opcion,array("2_1_1","3_3_1"))){
			$element = new Zend_Form_Element_File('archivo');
			$element->setLabel('Adjuntar archivo :');
	        $element->setMaxFileSize(10485760);
			$element->addValidator('Size', false, 10485760); // 10MB = 10,485,760 bytes
	        $element->setDestination($appConfig->get("ruta_archivos"));
	        $element->setRequired($sesionTabBoton->requerido);
	        $element->setValueDisabled(true);
	        $element->addValidator('Extension', false, $domConfig->EXTENSIONES_ARCHIVOS);
			$array_elements[] = $element;
		}
		
		if(in_array($sesionTabBoton->opcion,array("3_3_4","3_3_5","3_3_6"))){
	        $element = new Zend_Form_Element_Textarea('contenido1');
			$element->setLabel('Síntesis :');
			$element->setRequired($sesionTabBoton->requerido1);
//			$element->addFilter('StripTags');
			$element->addFilter('StringTrim');
//			$element->addFilter('StringToUpper');
			$element->setAttrib("rows",5);
			$element->setAttrib("style","width:99%");
			$element->addValidator('StringLength', false, array($domConfig->TEXTO_TAMANOMIN));
			$array_elements[] = $element;
			
			$element = new Zend_Form_Element_Hidden("codsintesis1");
	        $array_elements[] = $element;
		}

		if($sesionTabBoton->opcion=="3_3_5"){
	        $element = new Zend_Form_Element_Textarea('contenido2');
			$element->setLabel('Síntesis :');
			$element->setRequired($sesionTabBoton->requerido2);
//			$element->addFilter('StripTags');
			$element->addFilter('StringTrim');
//			$element->addFilter('StringToUpper');
			$element->setAttrib("rows",5);
			$element->setAttrib("style","width:99%");
		    $element->addValidator('StringLength', false, array($domConfig->TEXTO_TAMANOMIN));
			$array_elements[] = $element;
					
			$element = new Zend_Form_Element_Hidden("codsintesis2");
			$array_elements[] = $element;
					
	        $element = new Zend_Form_Element_Textarea('contenido3');
			$element->setLabel('Síntesis :');
			$element->setRequired(false);
//			$element->addFilter('StripTags');
			$element->addFilter('StringTrim');
//			$element->addFilter('StringToUpper');
			$element->setAttrib("rows",5);
			$element->setAttrib("style","width:99%");
			$element->addValidator('StringLength', false, array($domConfig->TEXTO_TAMANOMIN));
			$array_elements[] = $element;
			
			$element = new Zend_Form_Element_Hidden("codsintesis3");
			$array_elements[] = $element;
		}
		
		$element = new Zend_Form_Element_Submit ( 'btnSubmit' );
		$element->setValue('Guardar');
		$element->setLabel("Guardar");
		$element->setAttrib("class", "iceCmdBtn");
		$array_elements[] = $element;
		
        $this->addElements ($array_elements);
		
		$this->loadViewScriptDecorators();
//		$this->loadTableDecorators();
	}
	
	public function loadViewScriptDecorators() {
		$this->setDecorators ( array (array ('viewScript', array ('viewScript' => 'viewscripts/sintesis_form.phtml' ) ) ) );
	}
}